package chapter13;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author liuziyang
 * @create 2018-03-25 21:26
 */
public class StreamTest {
    public static void main(String[] args) {
        List<String> strings = new ArrayList<>();
        Collections.addAll(strings, "Test1", "tesT2", "TEst1", "test2", "tTst3");
        Stream<String> stream = strings.stream();
        List<String> distinct = stream.map(String::toLowerCase).distinct().filter(x -> x.contains("1")).collect(Collectors.toList());
        distinct.forEach(System.out::println);

        stream = strings.stream();
        if (stream.anyMatch(x -> x.contains("test"))) {
            System.out.println("contains test!");
        }
    }
}
